import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

/**
 * 配置 Element-Plus 按需引入
 */
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

/**
 * 配置 Windi-CSS
 */
import WindiCSS from 'vite-plugin-windicss';

/**
 * 引入方法, 用于配置绝对src路径别名
 */
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),

    // 配置 Element-Plus 按需引入
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),

    // 配置 Windi-CSS
    WindiCSS(),
  ],

  // 配置src绝对路径 别名
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
    },
  },
});
